home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / exec / execlp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-28  |  2.0 KB  |  83 lines

  1. /* 
  2.  * execlp.c --
  3.  *
  4.  *    Source code for the execlp library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/exec/RCS/execlp.c,v 1.5 89/01/27 21:09:39 rab Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20. #include <stdlib.h>
  21. #include <varargs.h>
  22.  
  23. /*
  24.  * Library imports:
  25.  */
  26.  
  27. extern char **environ;
  28. extern execvp();
  29. extern char **_ExecArgs();
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * execlp --
  36.  *
  37.  *    Execute a process, using the current environment variable,
  38.  *    instead of an explicitly-supplied one, and with arguments
  39.  *    in-line instead of in a separate array.  Also, imitate the
  40.  *    shell's actions in trying each directory in a search path
  41.  *    (given by the "PATH" environment variable).
  42.  *
  43.  * Results:
  44.  *    This procedure returns only if the exec fails.  In this case
  45.  *    the return value is -1.
  46.  *
  47.  * Side effects:
  48.  *    Overlays the current process with a new image.  See the man
  49.  *    page for details.
  50.  *
  51.  *----------------------------------------------------------------------
  52.  */
  53.  
  54. #ifndef lint
  55. int
  56. execlp(va_alist)
  57.     va_dcl            /* Name of file containing program to exec,
  58.                  * followed by one or more arguments of type
  59.                  * "char *", terminated by a zero argument. */
  60. {
  61.     char *name;
  62.     char **argv;
  63.     va_list args;
  64.  
  65.     va_start(args);
  66.     name = va_arg(args, char *);
  67.     argv = _ExecArgs(&args);
  68.     execvp(name, argv);
  69.     free((char *) argv);
  70.     return -1;
  71. }
  72. #else
  73. /* VARARGS2 */
  74. /* ARGSUSED */
  75. int
  76. execlp(file, arg1)
  77.     char *file;
  78.     char *arg1;
  79. {
  80.     return 0;
  81. }
  82. #endif
  83.